﻿using System;
using System.Collections.Generic;

namespace NetTopologySuite.Noding
{
	public class FastSegmentSetIntersectionFinder
	{
		public FastSegmentSetIntersectionFinder(IEnumerable<ISegmentString> baseSegStrings)
		{
			this._segSetMutInt = new MCIndexSegmentSetMutualIntersector(baseSegStrings);
		}

		public ISegmentSetMutualIntersector SegmentSetIntersector
		{
			get
			{
				return this._segSetMutInt;
			}
		}

		public bool Intersects(IList<ISegmentString> segStrings)
		{
			SegmentIntersectionDetector intDetector = new SegmentIntersectionDetector();
			return this.Intersects(segStrings, intDetector);
		}

		public bool Intersects(IList<ISegmentString> segStrings, SegmentIntersectionDetector intDetector)
		{
			this._segSetMutInt.Process(segStrings, intDetector);
			return intDetector.HasIntersection;
		}

		private readonly ISegmentSetMutualIntersector _segSetMutInt;
	}
}
